﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="frmEnvase.aspx.cs" Inherits="frmEmpaque" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2" Runat="Server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">

        <h1>Agregar Nuevo Envase</h1>
        <table>
        <tr>
        <td>Tipo</td><td>
        <p>Capacidad</p>
            </td><td>
                Unidad de medida&nbsp;&nbsp;&nbsp;&nbsp;
            </td><td>
        <p>Presentacion</p>
            </td>
        </tr>
        <tr>
        <td>
            <asp:DropDownList ID="DropDownList1" runat="server" 
                DataSourceID="SqlDataSource3" DataTextField="descripcion" 
                DataValueField="idTipo" Height="27px" Width="176px">
            </asp:DropDownList>
            <asp:SqlDataSource ID="SqlDataSource3" runat="server" 
                ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
                SelectCommand="SELECT * FROM [T_TipoEnvase]"></asp:SqlDataSource>
            </td><td valign="top"><asp:TextBox ID="TextBox2" runat="server" Height="25px" 
                    Width="85px"></asp:TextBox>
            </td><td valign="top">
                <asp:DropDownList ID="DropDownList2" runat="server" 
                    DataSourceID="SqlDataSource4" DataTextField="descripcion" 
                    DataValueField="idUnidad" Height="30px" Width="104px">
                </asp:DropDownList>
                <asp:SqlDataSource ID="SqlDataSource4" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
                    SelectCommand="SELECT * FROM [T_UnidadMedida]"></asp:SqlDataSource>
            </td><td><asp:TextBox ID="TextBox3" runat="server" Height="27px" Width="175px"></asp:TextBox>
            </td>
        </tr>
        <tr>
        <td>&nbsp;</td><td colspan="2"><asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" 
                ControlToValidate="TextBox2" ErrorMessage="Ingrese una capacidad" 
                Font-Bold="True" ForeColor="Red"></asp:RequiredFieldValidator>
            </td><td><asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" 
                ControlToValidate="TextBox3" ErrorMessage="Ingrese una presentación" 
                Font-Bold="True" ForeColor="Red"></asp:RequiredFieldValidator>
            </td>
        </tr>
        <tr>
        <td><asp:Button ID="Button1" runat="server" Height="34px" onclick="Button1_Click" 
                Text="Agregar" Width="185px" />
            </td><td colspan="2"><asp:Button ID="Button2" runat="server" CausesValidation="False" Height="34px" 
                onclick="Button2_Click" Text="Regresar " Width="185px" />
            </td><td><asp:Label ID="Label1" runat="server"></asp:Label>
                        </td><td>&nbsp;</td><td>&nbsp;</td>
        </tr>


        <table>
        
        <p>
            <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
                ConnectionString="<%$ ConnectionStrings:BD_SAFA_FINALConnectionString1 %>" 
                DeleteCommand="DELETE FROM [T_Envase] WHERE [idEnvase] = @idEnvase" 
                InsertCommand="INSERT INTO [T_Envase] ([tipoEnvase], [capacidadEnvase], [presentacionEnvase],[habilitado]) VALUES (@tipoEnvase, @capacidadEnvase, @presentacionEnvase,'1')" 
                SelectCommand="SELECT [idEnvase], [tipoEnvase], [capacidadEnvase], [presentacionEnvase] FROM [T_Envase]" 
                
                UpdateCommand="UPDATE [T_Envase] SET [tipoEnvase] = @tipoEnvase, [capacidadEnvase] = @capacidadEnvase, [presentacionEnvase] = @presentacionEnvase WHERE [idEnvase] = @idEnvase">
                <DeleteParameters>
                    <asp:Parameter Name="idEnvase" Type="Int32" />
                </DeleteParameters>
                <InsertParameters>
                    <asp:Parameter Name="tipoEnvase" Type="String" />
                    <asp:Parameter Name="capacidadEnvase" Type="String" />
                    <asp:Parameter Name="presentacionEnvase" Type="String" />
                </InsertParameters>
                <UpdateParameters>
                    <asp:Parameter Name="tipoEnvase" Type="String" />
                    <asp:Parameter Name="capacidadEnvase" Type="String" />
                    <asp:Parameter Name="presentacionEnvase" Type="String" />
                    <asp:Parameter Name="idEnvase" Type="Int32" />
                </UpdateParameters>
            </asp:SqlDataSource>
        </p>
        
       
        <p>
                        <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
                            ConnectionString="<%$ ConnectionStrings:BD_SAFA_FINALConnectionString1 %>" 
                            DeleteCommand="UPDATE [T_Envase] SET [habilitado] = '0' WHERE [idEnvase] = @idEnvase" 
                            InsertCommand="INSERT INTO [T_Envase] ([tipoEnvase], [capacidadEnvase], [presentacionEnvase]) VALUES (@tipoEnvase, @capacidadEnvase, @presentacionEnvase)" 
                            SelectCommand="SELECT [idEnvase], [tipoEnvase], [capacidadEnvase], [presentacionEnvase] FROM [T_Envase] where [habilitado] &gt;0" 
                            
                            UpdateCommand="UPDATE [T_Envase] SET [tipoEnvase] = @tipoEnvase, [capacidadEnvase] = @capacidadEnvase, [presentacionEnvase] = @presentacionEnvase WHERE [idEnvase] = @idEnvase">
                            <DeleteParameters>
                                <asp:Parameter Name="idEnvase" Type="Int32" />
                            </DeleteParameters>
                            <InsertParameters>
                                <asp:Parameter Name="tipoEnvase" Type="String" />
                                <asp:Parameter Name="capacidadEnvase" Type="String" />
                                <asp:Parameter Name="presentacionEnvase" Type="String" />
                            </InsertParameters>
                            <UpdateParameters>
                                <asp:Parameter Name="tipoEnvase" Type="String" />
                                <asp:Parameter Name="capacidadEnvase" Type="String" />
                                <asp:Parameter Name="presentacionEnvase" Type="String" />
                                <asp:Parameter Name="idEnvase" Type="Int32" />
                            </UpdateParameters>
                        </asp:SqlDataSource>
                    <p>
            <br /><hr />
            <b>Envases Registrados</b>
            <hr />
        <br />
        <asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
                            AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="idEnvase" 
                            DataSourceID="SqlDataSource2" 
                            
    EmptyDataText="No hay registros de datos para mostrar." Width="627px" 
                            BackColor="White" BorderColor="White" 
    BorderStyle="Ridge" BorderWidth="2px" 
                            CellPadding="3" CellSpacing="1" GridLines="None" 
    PageSize="3">
                            <Columns>
                                <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" 
                                    CausesValidation="False" 
                                    CancelImageUrl="~/Img/ico_chico_cancelar.png" 
                                    DeleteImageUrl="~/Img/ico_chico_eliminar.png" HeaderText="Acciones" 
                                    ButtonType="Image" EditImageUrl="~/Img/ico_chico_edicion.png" 
                                    UpdateImageUrl="~/Img/ico_chico_ok.png" >
                                <ItemStyle HorizontalAlign="Center" />
                                </asp:CommandField>
                                <asp:BoundField DataField="idEnvase" HeaderText="Codigo Envase" ReadOnly="True" 
                                    SortExpression="idEnvase" />
                                <asp:BoundField DataField="tipoEnvase" HeaderText="Tipo de Envase" 
                                    SortExpression="tipoEnvase" />
                                <asp:BoundField DataField="capacidadEnvase" HeaderText="Capacidad" 
                                    SortExpression="capacidadEnvase" />
                                <asp:BoundField DataField="presentacionEnvase" HeaderText="Presentacion" 
                                    SortExpression="presentacionEnvase" />
                            </Columns>
                            <FooterStyle BackColor="#C6C3C6" ForeColor="Black" />
                            <HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#E7E7FF" />
                            <PagerStyle BackColor="#C6C3C6" ForeColor="Black" HorizontalAlign="Right" />
                            <RowStyle BackColor="#DEDFDE" ForeColor="Black" />
                            <SelectedRowStyle BackColor="#9471DE" Font-Bold="True" ForeColor="White" />
                            <SortedAscendingCellStyle BackColor="#F1F1F1" />
                            <SortedAscendingHeaderStyle BackColor="#594B9C" />
                            <SortedDescendingCellStyle BackColor="#CAC9C9" />
                            <SortedDescendingHeaderStyle BackColor="#33276A" />
                        </asp:GridView>
                        <br />
        </p>
</asp:Content>

